package com.mouse.magent.web.util;

import com.mouse.magent.web.entity.common.JwtInfo;

public class UserContext {
    private ThreadLocal<JwtInfo> thisUser = new ThreadLocal<>();

    public static UserContext getInstance() {
        return SingletonHolder.sInstance;
    }

    private static class SingletonHolder {
        private static final UserContext sInstance = new UserContext();
    }

    public void setContext(JwtInfo jwtInfo) {
        thisUser.set(jwtInfo);
    }

    public JwtInfo getContext() {
        return thisUser.get();
    }

    public void clear() {
        thisUser.remove();
    }
}
